import allure
import jsonpath

from utils.send_request import send_jdbc_request

def get_http_data(case,res,all):
    if case["jsonExData"]:
        with allure.step("json提取"):
            for key, value in eval(case["jsonExData"]).items():
                value = jsonpath.jsonpath(res.json(), value)[0]
                all[key] = value
            return all

def get_sql_data(case,all):
    if case["sqlExData"]:
        with allure.step("sql提取"):
            for key, value in eval(case["sqlExData"]).items():
                # 建驴
                # cur.execute(value)
                # result=cur.fetchall()#返回的是一个[("admin")，("123")]
                result = send_jdbc_request(value)
                all[key] = result
            return all
